Repository navigation
Import mqtt in the import executor when @mqtt_trigger starts - #930
Merged
craigbarratt merged 1 commit intoNov 26, 2026
Merged
Conversation
Since the legacy mqtt.py was removed, homeassistant.components.mqtt (and paho) was imported only by decorators/mqtt.py, which DecoratorRegistry.init() loads in the event loop, so Home Assistant logged a blocking call when MQTT isn't set up. MQTTTriggerDecorator.start() now imports it with async_import_module(), which runs the import in the import executor.
craigbarratt
approved these changes
Nov 26, 2026
craigbarratt
left a comment
Member
There was a problem hiding this comment.
Thanks @dmamelin, good catch. I checked that loading pyscript and its decorators no longer imports homeassistant.components.mqtt or paho (on master it imports both), and that the existing @mqtt_trigger test goes through the new import in start().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small follow-up to #927 that fixes a regression: a blocking-call warning at startup when MQTT isn't set up.
Before #927, the legacy
mqtt.pyimportedhomeassistant.components.mqtt(and paho) while Home Assistant was loading pyscript in its import executor. Now onlydecorators/mqtt.pyimports it, and the decorators are loaded byDecoratorRegistry.init()fromasync_setup_entry(), which runs in the event loop.@mqtt_triggernow imports mqtt withasync_import_module()when it starts, so it's loaded in the import executor, and only when the decorator is used. When MQTT is set up, Home Assistant has already loaded it (after_dependencies), so this just returns the loaded module.